﻿using Code;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

namespace Models {
    public class CashLog {
        public long Id { get; set; }

        [Required, Column("CreateTime", TypeName = "datetime")]
        [DisplayName("申请时间")]
        [List("Order", 100)]
        public DateTime CreateTime { get; set; } = DateTime.Now;

        [Required, Column("CashNo", TypeName = "varchar(50)")]
        [DisplayName("提现流水号")]
        [List("Order", 0)]
        public string CashNo { get; set; }

        /// <summary>
        /// 申请提现金额
        /// </summary>
        [Required, Column("Price", TypeName = "money")]
        public decimal Price { get; set; }

        [DisplayName("提现金额")]
        public string strPrice {
            get {
                return Price.ToString("C");
            }
        }

        /// <summary>
        /// 手续费
        /// </summary>
        [Required, Column("Handlingfee", TypeName = "varchar(10)")]
        public string Handlingfee { get; set; }

        [DisplayName("手续费")]
        public string strFee {
            get {
                decimal.TryParse(Handlingfee, out decimal fee);

                return (Price * fee).ToString("C");
            }
        }

        /// <summary>
        /// 实际金额
        /// </summary>
        [Required, Column("RealPrice", TypeName = "money")]
        public decimal RealPrice { get; set; }

        [DisplayName("出账金额")]
        public string strRealPrice {
            get {
                return RealPrice.ToString("C");
            }
        }

        /// <summary>
        /// 提现状态
        /// </summary>
        [Required, Column("Status", TypeName = "smallint")]
        public CashStatus Status { get; set; }

        [DisplayName("状态")]
        public string strStatus {
            get {
                return Status.ToString();
            }
        }

        [Required]
        public long UserId { get; set; }
    }

    public class CashLogExt : CashLog {
        [DisplayName("申请会员")]
        public string UserName { get; set; }
    }
}
